(module every (lib "eopl.ss" "eopl")
  (provide every?)
  
;; 1.23
;;every?: pred lst ==> #f or #t
;;usage: (every? pred lst)
;;produces:

;;examples:
;;(every? number? '(a b c 3 e)) ==> #f
;;(every? number? '(1 2 3 4 5)) ==> #t

(define every? 
  (lambda (pred lst)
    (cond 
      ((null? lst) #f)
      (else (pred-help #t pred lst))
      )
    )
  )

;;examples:
;;(pred-help #t number? '(1 2 3 4)) ==> #t
;; (pred-help #t number? '(1 2 b  4)) ==>#f
(define pred-help
  (lambda (bool pred list)
    (cond
      ((null? list) bool)
      ((pred (car list)) (pred-help bool pred (cdr list)))
      (else #f)
      )
    )
  )
  
;;Tests
(every? number? '(a 1 3 5))
(every? symbol? '(a f d))

) 